package com.app.miwawa.api.system.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.framework.common.api.entity.CommonEntityUUID;
import org.framework.common.ext.util.StringUtil;
import org.springframework.format.annotation.DateTimeFormat;

import com.app.miwawa.api.system.service.bo.AdminBo;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 系统管理－平台管理员
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date 2016年2月7日 下午12:04:51
 * @version 1.0.2016
 */
@Entity @Table(name = "TB_SYSTEM_ADMIN")
public class Admin extends CommonEntityUUID {

	/** serialVersionUID(long):. */
	private static final long serialVersionUID = -6714998278207298993L;

	// 类型(super=超级管理员、center=)
	@Column(name = "type", length = 10, nullable = true)
	private	String type;
	
	// 名称
	@Column(name = "name", length = 50, nullable = true)
	private String name;
	
	// 邮箱
	@Column(name = "email", length = 50, nullable = true)
	private String email;
	
	// 邮箱
	@Column(name = "mobile", length = 50, nullable = true)
	private String mobile;
	
	// 帐号
	@Column(name = "account", length = 50, nullable = true)
	private String account;
	
	// 密码
	@Column(name = "password", length = 50, nullable = true)
	private String password;
	
	// 创建时间
	@Temporal(TemporalType.DATE)
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@Column(name = "create_date", nullable = true)
	private Date createDate;
		
	// 中心
	@Column(name = "center", length = 50, nullable = true)
	private String center;
		
	// 中心ID
	@Column(name = "center_id", length = 50, nullable = true)
	private String centerid;
	
	@Transient
	private String dbname;
	
	@Transient
	private String prefix;
	
	/**
	 * 检查管理员账户.
	 * 
	 * @param bo
	 * @return
	 * @author chanlong(陈龙)
	 * @date 2016年3月18日 上午11:25:04
	 */
	public Admin checkAccount(final AdminBo bo){
		return bo.checkAccount(this);
	}
	
	/**
	 * 检查管理员密码.
	 * 
	 * @param bo
	 * @return
	 * @author chanlong(陈龙)
	 * @date 2016年3月18日 上午11:25:19
	 */
	public Admin checkPassword(final AdminBo bo){
		return bo.checkPassword(this);
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}
	
	public void setAccount(StringBuilder account) {
		this.account = account.toString();
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = StringUtil.password(password);
	}

	public String getCenter() {
		return center;
	}

	public void setCenter(String center) {
		this.center = center;
	}

	public String getCenterid() {
		return centerid;
	}

	public void setCenterid(String centerid) {
		this.centerid = centerid;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getDbname() {
		return dbname;
	}

	public void setDbname(String dbname) {
		this.dbname = dbname;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
}
